home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Programming / HBasicGolded / Files / Scripts / HB_Functions.rexx < prev   
OS/2 REXX Batch file  |  2000-01-18  |  2KB  |  88 lines

  1. /* Script to save a dictionary of HBasic OS3 file1 */
  2.  
  3.  
  4. /* get the directory path of the images */
  5. PARSE ARG  dirname
  6.  
  7. /* strip extranneous spaces and quotes */
  8. dirname = STRIP(dirname)
  9. dirname = STRIP(dirname,"b",'"')
  10. dirname = STRIP(dirname)
  11. IF RIGHT(dirname,1) ~= "/"  & RIGHT(dirname,1) ~=":"  then ; dirname=dirname||"/"
  12.  
  13. /* create a list of BH files in the temporary file in RAM */
  14. commandline = "list >ram:"||tempname||" "dirname"#?.(bh) files LFORMAT %P%S"
  15. ADDRESS COMMAND commandline
  16. ADDRESS COMMAND 'c:Sort RAM:tempname TO RAM:tamlist.temp'
  17.  
  18. /* Open the file and read in names to filename compound variable */
  19. inname = "ram:tamlist.temp"
  20. q =  OPEN("infile", inname, "R")
  21. filecount = 1
  22.  
  23. do UNTIL EOF("infile")
  24.    filename.filecount = READLN("infile")
  25.    filecount = filecount+1
  26. end
  27.  
  28. /* Remember to close and delete the temporary file */
  29. CALL CLOSE("infile")
  30.  
  31.  
  32. ADDRESS COMMAND "delete ram:"||tempname
  33.  
  34. SAY filecount "Files have been found"
  35.  
  36.  
  37. /* CREATE OUTPUT FILES */
  38. CALL OPEN(file1, "Ram:Functions", "W")
  39. CALL OPEN(file2, "Ram:Subs", "W")
  40.  
  41.     do loop = 1 to filecount-2  /* MAIN LOOP */
  42.  
  43.         File=filename.loop
  44.         CALL WRITELN(FILE1, "/*" File "*/")
  45.         CALL WRITELN(FILE2, "/*" File "*/")
  46.         LineLength1=0
  47.         LineLength2=0
  48.  
  49.         CALL OPEN("Data_File", File, "R")
  50.             do UNTIL EOF("Data_File")
  51.                Textline = READLN("Data_File")
  52.                TYPE = CHECKTYPE(Textline)
  53.                IF TYPE="FUNCTION" THEN ; LineLength1 = FileWrite(LineLength1,FILE1)
  54.                IF TYPE="SUB" THEN ; LineLength2 = FileWrite(LineLength2,FILE2)
  55.             end
  56.         CALL WRITELN(FILE1, "");CALL WRITELN(FILE1, "")
  57.         CALL WRITELN(FILE2, "");CALL WRITELN(FILE2, "")
  58.         CALL CLOSE("Data_File")
  59.  
  60.  
  61.     end  /* END of Main Loop */
  62.  
  63. /* Close Output Files */
  64. CALL CLOSE(file1)
  65. CALL CLOSE(file2)
  66.  
  67. EXIT
  68.  
  69. CHECKTYPE: EXPOSE Header
  70. TYPE = WORD(Textline,2)
  71. Header = WORD(Textline,3)
  72. RETURN TYPE
  73.  
  74. FILEWRITE: PROCEDURE Expose Header
  75. LineLength = Arg(1)
  76. FILE = Arg(2)
  77.                  LineLength = LineLength + LENGTH(Header)
  78.                  IF LineLength > 120 THEN
  79.                  DO
  80.                     CALL WRITELN(FILE,"")
  81.                     LineLength = LENGTH(Header)
  82.                  END
  83.                  CALL WRITECH(FILE,Header||" ")
  84. RETURN LineLength
  85.  
  86.  
  87.  
  88.